package com.gxa.autoparts.portal.controller;

import com.gxa.autoparts.core.common.JsonResult;

import com.gxa.autoparts.core.exception.BusinessException;
import com.gxa.autoparts.core.pojo.UserVipVo;
import com.gxa.autoparts.core.util.ThreadLocalUtil;
import com.gxa.autoparts.portal.service.UserVipService;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/userWantVipController")
@Api(tags = "用户申请会员")
public class UserWantVipController {

    @Autowired
    private UserVipService userVipService=null;
    @PostMapping("/applyVip")
    @ApiOperation("申请会员")
//    @ApiOperation("申请会员")@RequestParam("factoryName") String factoryName,@RequestParam("doorName") String doorName,
//    @RequestParam("name") String name,@RequestParam("phone") String phone,
//    @RequestParam("address") String address, @RequestParam("licenseImg") String licenseImg,
//    @RequestParam("list") List<String> list
    public Map applyVip(@RequestBody UserVipVo userVipVo) throws BusinessException {
        userVipVo.getVip().setUserId(1L);
        userVipService.applyVip(userVipVo);
        //使用ThreadLocal得到用户id

        System.out.println(userVipVo);
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("200");
        return jsonResult.getDataMap();

    }
    @PostMapping("/vipDetail")
    @ApiOperation("查看会员进度")
    public Map vipDetail() throws BusinessException {
        UserVipVo userVipVo = userVipService.vipDetail(1L);
        //使用ThreadLocal得到用户id
        JsonResult jsonResult=new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(userVipVo);
        return jsonResult.getDataMap();

    }
}
